<template>
  <div class="">
    <div>
      <!-- 顶部导航栏 -->
      <navigation />
    </div>
    <!-- 云音乐特色榜 -->
    <div class="container w">
      <div class="top1">
        <div class="head">云音乐特色榜</div>
        <ul class="box">
          <li
            v-for="(item, index) in GetTop1"
            :key="index"
            @click="change(item.id)"
          >
            <div class="pic">
              <img :src="item.coverImgUrl" alt="" />
              <span class="el-icon-caret-right">{{
                item.playCount | formatCount
              }}</span>
            </div>
            <span class="text">{{ item.name }}</span>
          </li>
        </ul>
      </div>
    </div>

    <!-- 全球媒体榜 -->
    <div class="container w">
      <div class="top1">
        <div class="head">全球媒体榜</div>
        <ul class="box">
          <li
            v-for="(item, index) in GetTop2"
            :key="index"
            @click="change(item.id)"
          >
            <div class="pic">
              <img :src="item.coverImgUrl" alt="" />
              <span class="el-icon-caret-right">{{
                item.playCount | formatCount
              }}</span>
            </div>
            <span class="text">{{ item.name }}</span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import navigation from "../../components/navigation/NaviGation";
import { GetTop1 } from "../../network/index";
export default {
  name: "top",
  data() {
    return {
      GetTop1: [],
      GetTop2: [],
    };
  },
  components: {
    navigation,
    GetTop1,
  },
  created() {
    GetTop1().then((res) => {
      console.log(res);
      if (res.data.code == "200") {
        this.GetTop1 = res.data.list.splice(0, 4);
        this.GetTop2 = res.data.list.splice(3);

        console.log(this.GetTop2);
      }
    });
  },
  methods: {
    change(id) {
      this.$router.push({
        //核心语句
        path: "/playlistitem", //跳转的路径
        query: {
          //路由传参时push和query搭配使用 ，作用时传递参数
          id: id,
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  margin-top: 105px;
  .top1 {
    .head {
      padding-left: 20px;
      height: 20px;
      line-height: 20px;
      border-left: 2px solid #fa2800;
      font-size: 16px;
      font-weight: 700;
      color: #000;
    }
    .box {
      display: flex;
      flex-wrap: wrap;
      li {
        width: 150px;
        // height: 160px;
        padding: 10px;
        cursor: pointer;

        // margin-bottom: 15px;
        .pic {
          position: relative;
          img {
            width: 100%;
            box-shadow: 10px 10px 10px #999;
            border-radius: 10px;
          }
          span {
            position: absolute;
            right: 10px;
            top: 10px;
            color: #fff;
            background-color: #000;
            padding: 5px;
            border-radius: 10px;
          }
        }
        .text {
          display: inline-block;
          // height: 25px;
          // line-height: 25px;
          font-size: 16px;
          font-weight: 700;
          padding-top: 10px;
        }
      }
    }
  }
}
</style>
